package com.youyi.yyviewsdklibrary.Dialog.util;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Toast;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.youyi.yychosesdk.utils.file.FileUtils;
import com.youyi.yyviewsdklibrary.Dialog.core.AttachPopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.BubbleAttachPopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.PositionPopupView;
import com.youyi.yyviewsdklibrary.Dialog.impl.FullScreenPopupView;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.XPopupImageLoader;
import com.lkx.liandianqinew.R;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.Executors;

public class XPopupUtils {
    private static final char[] HEX_DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    private static final char[] HEX_DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    private static int preKeyboardHeight;
    private static int sDecorViewDelta;

    public static void setCursorDrawableColor(EditText editText, int i) {
    }

    public static void saveBmpToAlbum(final Context context, final XPopupImageLoader xPopupImageLoader, final Object obj) {
        Executors.newSingleThreadExecutor().execute(new Runnable() {

            public void run() {
                File imageFile =xPopupImageLoader.getImageFile(context, obj);
                if (imageFile == null) {
                    XPopupUtils.showToast(context, context.getString(R.string.xpopup_image_not_exist));
                    return;
                }
                try {
                    File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), context.getPackageName());
                    if (!file.exists()) {
                        file.mkdirs();
                    }
                    File file2 = new File(file, System.currentTimeMillis() + "." + XPopupUtils.getImageType(imageFile));
                    if (Build.VERSION.SDK_INT < 29) {
                        if (file2.exists()) {
                            file2.delete();
                        }
                        file2.createNewFile();
                        FileOutputStream fileOutputStream = new FileOutputStream(file2);
                        try {
                            XPopupUtils.writeFileFromIS(fileOutputStream, new FileInputStream(imageFile));
                            fileOutputStream.close();
                            Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
                            intent.setData(Uri.parse("file://" + file2.getAbsolutePath()));
                            context.sendBroadcast(intent);
                        } catch (Throwable th) {
                            th.addSuppressed(th);
                        }
                    } else {
                        XPopupUtils.noticSystem(context, imageFile.getAbsolutePath());
                    }
                    Context context2 = context;
                    XPopupUtils.showToast(context2, context2.getString(R.string.xpopup_saved_to_gallery));
                    return;
                } catch (Exception e) {
                    e.printStackTrace();
                    Context context3 = context;
                    XPopupUtils.showToast(context3, context3.getString(R.string.xpopup_saved_fail));
                    return;
                }
            }
        });
    }

    public static void noticSystem(Context context, String str) {
        try {
            File file = new File(str);
            try {
                MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), file.getName(), (String) null);
            } catch (Exception e) {
                e.printStackTrace();
            }
            Uri fromFile = Uri.fromFile(new File(str));
            if (Build.VERSION.SDK_INT >= 24) {
                fromFile = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", new File(str));
            }
            context.sendBroadcast(new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE", fromFile));
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public static int getAppHeight(Context context) {
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (windowManager == null) {
            return -1;
        }
        Point point = new Point();
        windowManager.getDefaultDisplay().getSize(point);
        return point.y;
    }

    public static int getAppWidth(Context context) {
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (windowManager == null) {
            return -1;
        }
        Point point = new Point();
        windowManager.getDefaultDisplay().getSize(point);
        return point.x;
    }

    public static int getScreenHeight(Context context) {
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (windowManager == null) {
            return -1;
        }
        Point point = new Point();
        windowManager.getDefaultDisplay().getRealSize(point);
        return point.y;
    }

    public static int getScreenWidth(Context context) {
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (windowManager == null) {
            return -1;
        }
        Point point = new Point();
        windowManager.getDefaultDisplay().getRealSize(point);
        return point.x;
    }

    public static int dp2px(Context context, float f) {
        return (int) ((f * context.getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static int getStatusBarHeight() {
        Resources system = Resources.getSystem();
        return system.getDimensionPixelSize(system.getIdentifier("status_bar_height", "dimen", "android"));
    }

    public static int getNavBarHeight() {
        Resources system = Resources.getSystem();
        int identifier = system.getIdentifier("navigation_bar_height", "dimen", "android");
        if (identifier != 0) {
            return system.getDimensionPixelSize(identifier);
        }
        return 0;
    }

    public static void setWidthHeight(View view, int i, int i2) {
        if (i > 0 || i2 > 0) {
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            if (i > 0) {
                layoutParams.width = i;
            }
            if (i2 > 0) {
                layoutParams.height = i2;
            }
            view.setLayoutParams(layoutParams);
        }
    }

    public static void applyPopupSize(final ViewGroup viewGroup, final int i, final int i2, final int i3, final int i4, final Runnable runnable) {
        viewGroup.post(new Runnable() {
            /* class com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.AnonymousClass2 */

            public void run() {
                ViewGroup.LayoutParams layoutParams = viewGroup.getLayoutParams();
                View childAt = viewGroup.getChildAt(0);
                ViewGroup.LayoutParams layoutParams2 = childAt.getLayoutParams();
                int measuredWidth = viewGroup.getMeasuredWidth();
                if (i > 0) {
                    layoutParams.width = Math.min(measuredWidth, i);
                    if (layoutParams2.width == -1) {
                        layoutParams2.width = Math.min(measuredWidth, i);
                    }
                    int i2 = i3;
                    if (i2 > 0) {
                        layoutParams.width = Math.min(i2, i);
                        layoutParams2.width = Math.min(i3, i);
                    }
                } else {
                    if (i3 > 0) {
                        layoutParams.width = i3;
                        layoutParams2.width = i3;
                    }
                }
                if (i2 > 0) {
                    layoutParams.height = Math.min(viewGroup.getMeasuredHeight(), i2);
                    if (i4 > 0) {
                        layoutParams.height = Math.min(i4, i2);
                        layoutParams2.height = Math.min(i4, i2);
                    }
                } else {
                    int i5 = i4;
                    if (i5 > 0) {
                        layoutParams.height = i5;
                        layoutParams2.height = i4;
                    }
                }
                childAt.setLayoutParams(layoutParams2);
                viewGroup.setLayoutParams(layoutParams);
                viewGroup.post(new Runnable() {

                    public void run() {
                        if (runnable != null) {
                            runnable.run();
                        }
                    }
                });
            }
        });
    }

    public static BitmapDrawable createBitmapDrawable(Resources resources, int i, int i2) {
        Bitmap createBitmap = Bitmap.createBitmap(i, 20, Bitmap.Config.ARGB_4444);
        Canvas canvas = new Canvas(createBitmap);
        Paint paint = new Paint();
        paint.setColor(i2);
        canvas.drawRect(0.0f, 0.0f, (float) createBitmap.getWidth(), 4.0f, paint);
        paint.setColor(0);
        canvas.drawRect(0.0f, 4.0f, (float) createBitmap.getWidth(), 20.0f, paint);
        BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, createBitmap);
        bitmapDrawable.setGravity(80);
        return bitmapDrawable;
    }

    public static StateListDrawable createSelector(Drawable drawable, Drawable drawable2) {
        StateListDrawable stateListDrawable = new StateListDrawable();
        stateListDrawable.addState(new int[]{16842908}, drawable2);
        stateListDrawable.addState(new int[0], drawable);
        return stateListDrawable;
    }

    public static boolean isInRect(float f, float f2, Rect rect) {
        return f >= ((float) rect.left) && f <= ((float) rect.right) && f2 >= ((float) rect.top) && f2 <= ((float) rect.bottom);
    }

    public static int getDecorViewInvisibleHeight(Window window) {
        View decorView = window.getDecorView();
        Rect rect = new Rect();
        decorView.getWindowVisibleDisplayFrame(rect);
        int abs = Math.abs(decorView.getBottom() - rect.bottom);
        if (abs > getNavBarHeight()) {
            return abs - sDecorViewDelta;
        }
        sDecorViewDelta = abs;
        return 0;
    }

    public static void moveUpToKeyboard(int i, final BasePopupView basePopupView) {
        preKeyboardHeight = i;
        basePopupView.post(new Runnable() {
            /* class com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.AnonymousClass3 */

            public void run() {
                XPopupUtils.moveUpToKeyboardInternal(XPopupUtils.preKeyboardHeight, basePopupView);
            }
        });
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Code restructure failed: missing block: B:36:0x00b2, code lost:
        if (r8 > 0) goto L_0x00c8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:40:0x00c6, code lost:
        if (r8 > 0) goto L_0x00c8;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static void moveUpToKeyboardInternal(int r8, BasePopupView r9) {
        /*
        // Method dump skipped, instructions count: 233
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.moveUpToKeyboardInternal(int, com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView):void");
    }

    public static void moveDown(BasePopupView basePopupView) {
        if (!(basePopupView instanceof PositionPopupView) && !(basePopupView instanceof AttachPopupView) && !(basePopupView instanceof BubbleAttachPopupView)) {
            if (!(basePopupView instanceof FullScreenPopupView) || !basePopupView.getPopupContentView().hasTransientState()) {
                basePopupView.getPopupContentView().animate().translationY(0.0f).setDuration(100).start();
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:15:0x003c  */
    /* JADX WARNING: Removed duplicated region for block: B:37:? A[RETURN, SYNTHETIC] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean isNavBarVisible(Window r8) {
        /*
        // Method dump skipped, instructions count: 108
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.isNavBarVisible(android.view.Window):boolean");
    }

    public static void findAllEditText(ArrayList<EditText> arrayList, ViewGroup viewGroup) {
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View childAt = viewGroup.getChildAt(i);
            if ((childAt instanceof EditText) && childAt.getVisibility() == 0) {
                arrayList.add((EditText) childAt);
            } else if (childAt instanceof ViewGroup) {
                findAllEditText(arrayList, (ViewGroup) childAt);
            }
        }
    }

    /* access modifiers changed from: private */
    public static void showToast(final Context context, final String str) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            /* class com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.AnonymousClass4 */

            public void run() {
                if (context != null) {
                    Toast.makeText(context, str, 0).show();
                }
            }
        });
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x003e A[SYNTHETIC, Splitter:B:32:0x003e] */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x0051 A[SYNTHETIC, Splitter:B:42:0x0051] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean writeFileFromIS(java.io.OutputStream r5, java.io.InputStream r6) {
        /*
            r0 = 0
            r1 = 0
            java.io.BufferedOutputStream r2 = new java.io.BufferedOutputStream     // Catch:{ IOException -> 0x0030 }
            r2.<init>(r5)     // Catch:{ IOException -> 0x0030 }
            r5 = 8192(0x2000, float:1.14794E-41)
            byte[] r1 = new byte[r5]     // Catch:{ IOException -> 0x002b, all -> 0x0028 }
        L_0x000b:
            int r3 = r6.read(r1, r0, r5)     // Catch:{ IOException -> 0x002b, all -> 0x0028 }
            r4 = -1
            if (r3 == r4) goto L_0x0016
            r2.write(r1, r0, r3)     // Catch:{ IOException -> 0x002b, all -> 0x0028 }
            goto L_0x000b
        L_0x0016:
            r5 = 1
            r6.close()     // Catch:{ IOException -> 0x001b }
            goto L_0x001f
        L_0x001b:
            r6 = move-exception
            r6.printStackTrace()
        L_0x001f:
            r2.close()     // Catch:{ IOException -> 0x0023 }
            goto L_0x0027
        L_0x0023:
            r6 = move-exception
            r6.printStackTrace()
        L_0x0027:
            return r5
        L_0x0028:
            r5 = move-exception
            r1 = r2
            goto L_0x0047
        L_0x002b:
            r5 = move-exception
            r1 = r2
            goto L_0x0031
        L_0x002e:
            r5 = move-exception
            goto L_0x0047
        L_0x0030:
            r5 = move-exception
        L_0x0031:
            r5.printStackTrace()     // Catch:{ all -> 0x002e }
            r6.close()     // Catch:{ IOException -> 0x0038 }
            goto L_0x003c
        L_0x0038:
            r5 = move-exception
            r5.printStackTrace()
        L_0x003c:
            if (r1 == 0) goto L_0x0046
            r1.close()     // Catch:{ IOException -> 0x0042 }
            goto L_0x0046
        L_0x0042:
            r5 = move-exception
            r5.printStackTrace()
        L_0x0046:
            return r0
        L_0x0047:
            r6.close()     // Catch:{ IOException -> 0x004b }
            goto L_0x004f
        L_0x004b:
            r6 = move-exception
            r6.printStackTrace()
        L_0x004f:
            if (r1 == 0) goto L_0x0059
            r1.close()     // Catch:{ IOException -> 0x0055 }
            goto L_0x0059
        L_0x0055:
            r6 = move-exception
            r6.printStackTrace()
        L_0x0059:
            throw r5
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.writeFileFromIS(java.io.OutputStream, java.io.InputStream):boolean");
    }

    /* JADX WARNING: Removed duplicated region for block: B:14:0x0046  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static Bitmap renderScriptBlur(Context r2, Bitmap r3, float r4, boolean r5) {
        /*
            r0 = 1
            if (r5 == 0) goto L_0x0004
            goto L_0x000c
        L_0x0004:
            android.graphics.Bitmap$Config r5 = r3.getConfig()
            android.graphics.Bitmap r3 = r3.copy(r5, r0)
        L_0x000c:
            android.renderscript.RenderScript r2 = android.renderscript.RenderScript.create(r2)     // Catch:{ all -> 0x0042 }
            android.renderscript.RenderScript$RSMessageHandler r5 = new android.renderscript.RenderScript$RSMessageHandler     // Catch:{ all -> 0x0040 }
            r5.<init>()     // Catch:{ all -> 0x0040 }
            r2.setMessageHandler(r5)     // Catch:{ all -> 0x0040 }
            android.renderscript.Allocation$MipmapControl r5 = android.renderscript.Allocation.MipmapControl.MIPMAP_NONE     // Catch:{ all -> 0x0040 }
            android.renderscript.Allocation r5 = android.renderscript.Allocation.createFromBitmap(r2, r3, r5, r0)     // Catch:{ all -> 0x0040 }
            android.renderscript.Type r0 = r5.getType()     // Catch:{ all -> 0x0040 }
            android.renderscript.Allocation r0 = android.renderscript.Allocation.createTyped(r2, r0)     // Catch:{ all -> 0x0040 }
            android.renderscript.Element r1 = android.renderscript.Element.U8_4(r2)     // Catch:{ all -> 0x0040 }
            android.renderscript.ScriptIntrinsicBlur r1 = android.renderscript.ScriptIntrinsicBlur.create(r2, r1)     // Catch:{ all -> 0x0040 }
            r1.setInput(r5)     // Catch:{ all -> 0x0040 }
            r1.setRadius(r4)     // Catch:{ all -> 0x0040 }
            r1.forEach(r0)     // Catch:{ all -> 0x0040 }
            r0.copyTo(r3)     // Catch:{ all -> 0x0040 }
            if (r2 == 0) goto L_0x003f
            r2.destroy()
        L_0x003f:
            return r3
        L_0x0040:
            r3 = move-exception
            goto L_0x0044
        L_0x0042:
            r3 = move-exception
            r2 = 0
        L_0x0044:
            if (r2 == 0) goto L_0x0049
            r2.destroy()
        L_0x0049:
            throw r3
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.renderScriptBlur(android.content.Context, android.graphics.Bitmap, float, boolean):android.graphics.Bitmap");
    }

    public static Bitmap view2Bitmap(View view) {
        Bitmap bitmap;
        if (view == null) {
            return null;
        }
        boolean isDrawingCacheEnabled = view.isDrawingCacheEnabled();
        boolean willNotCacheDrawing = view.willNotCacheDrawing();
        view.setDrawingCacheEnabled(true);
        view.setWillNotCacheDrawing(false);
        Bitmap drawingCache = view.getDrawingCache();
        if (drawingCache == null) {
            view.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
            view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
            view.buildDrawingCache();
            Bitmap drawingCache2 = view.getDrawingCache();
            if (drawingCache2 != null) {
                bitmap = Bitmap.createBitmap(drawingCache2);
            } else {
                bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
                view.draw(new Canvas(bitmap));
            }
        } else {
            bitmap = Bitmap.createBitmap(drawingCache);
        }
        view.destroyDrawingCache();
        view.setWillNotCacheDrawing(willNotCacheDrawing);
        view.setDrawingCacheEnabled(isDrawingCacheEnabled);
        return bitmap;
    }

    public static boolean isLayoutRtl(Context context) {
        Locale locale;
        if (Build.VERSION.SDK_INT >= 24) {
            locale = context.getResources().getConfiguration().getLocales().get(0);
        } else {
            locale = context.getResources().getConfiguration().locale;
        }
        if (TextUtils.getLayoutDirectionFromLocale(locale) == 1) {
            return true;
        }
        return false;
    }

    public static Activity context2Activity(View view) {
        for (Context context = view.getContext(); context instanceof ContextWrapper; context = ((ContextWrapper) context).getBaseContext()) {
            if (context instanceof Activity) {
                return (Activity) context;
            }
        }
        return null;
    }

    public static Drawable createDrawable(int i, float f) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(0);
        gradientDrawable.setColor(i);
        gradientDrawable.setCornerRadius(f);
        return gradientDrawable;
    }

    public static Drawable createDrawable(int i, float f, float f2, float f3, float f4) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(0);
        gradientDrawable.setColor(i);
        gradientDrawable.setCornerRadii(new float[]{f, f, f2, f2, f3, f3, f4, f4});
        return gradientDrawable;
    }

    public static boolean hasSetKeyListener(View view) {
        try {
            Method declaredMethod = Class.forName("android.view.View").getDeclaredMethod("getListenerInfo", new Class[0]);
            if (!declaredMethod.isAccessible()) {
                declaredMethod.setAccessible(true);
            }
            Object invoke = declaredMethod.invoke(view, new Object[0]);
            Field declaredField = Class.forName("android.view.View$ListenerInfo").getDeclaredField("mOnKeyListener");
            if (!declaredField.isAccessible()) {
                declaredField.setAccessible(true);
            }
            if (declaredField.get(invoke) != null) {
                return true;
            }
            return false;
        } catch (Exception unused) {
            return false;
        }
    }

    public static int calculateInSampleSize(BitmapFactory.Options options, int i, int i2) {
        int i3 = options.outHeight;
        int i4 = options.outWidth;
        int i5 = 1;
        while (true) {
            if (i3 <= i2 && i4 <= i) {
                return i5;
            }
            i3 >>= 1;
            i4 >>= 1;
            i5 <<= 1;
        }
    }

    public static Bitmap getBitmap(File file, int i, int i2) {
        if (file == null) {
            return null;
        }
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(file.getAbsolutePath(), options);
        options.inSampleSize = calculateInSampleSize(options, i, i2);
        options.inJustDecodeBounds = false;
        return BitmapFactory.decodeFile(file.getAbsolutePath(), options);
    }

    public static int[] getImageSize(File file) {
        if (file == null) {
            return new int[]{0, 0};
        }
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(file.getAbsolutePath(), options);
        return new int[]{options.outWidth, options.outHeight};
    }

    /* JADX WARNING: Removed duplicated region for block: B:83:0x00cf  */
    /* JADX WARNING: Removed duplicated region for block: B:88:0x00da A[SYNTHETIC, Splitter:B:88:0x00da] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static String getImageType(File r4) {
        /*
        // Method dump skipped, instructions count: 227
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils.getImageType(java.io.File):java.lang.String");
    }

    public static String bytes2HexString(byte[] bArr, boolean z) {
        if (bArr == null) {
            return "";
        }
        char[] cArr = z ? HEX_DIGITS_UPPER : HEX_DIGITS_LOWER;
        int length = bArr.length;
        if (length <= 0) {
            return "";
        }
        char[] cArr2 = new char[(length << 1)];
        int i = 0;
        for (int i2 = 0; i2 < length; i2++) {
            int i3 = i + 1;
            cArr2[i] = cArr[(bArr[i2] >> 4) & 15];
            i = i3 + 1;
            cArr2[i3] = cArr[bArr[i2] & 15];
        }
        return new String(cArr2);
    }

    public static int getRotateDegree(String str) {
        try {
            int attributeInt = new ExifInterface(str).getAttributeInt(android.support.media.ExifInterface.TAG_ORIENTATION, 1);
            if (attributeInt == 3) {
                return 180;
            }
            if (attributeInt == 6) {
                return 90;
            }
            if (attributeInt != 8) {
                return 0;
            }
            return SubsamplingScaleImageView.ORIENTATION_270;
        } catch (IOException e) {
            e.printStackTrace();
            return -1;
        }
    }

    public static Bitmap rotate(Bitmap bitmap, int i, float f, float f2) {
        if (i == 0) {
            return bitmap;
        }
        Matrix matrix = new Matrix();
        matrix.setRotate((float) i, f, f2);
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    }

    public static Rect getViewRect(View view) {
        Rect rect = new Rect();
        view.getGlobalVisibleRect(rect);
        return rect;
    }

    public static boolean isLandscape(Context context) {
        return context.getResources().getConfiguration().orientation == 2;
    }

    public static boolean isTablet() {
        return (Resources.getSystem().getConfiguration().screenLayout & 15) >= 3;
    }
}
